//MyBlock.js - Creates a block with the name MyBlock and sets the texture
importPackage(com.blocks.blocks);
importPackage(com.blocks);
importPackage(com.blocks.model);
importPackage(com.jme3.math);
importPackage(java.lang);
importPackage(com.blocks.script);
importPackage(com.jme3.math);
importPackage(com.jme3.collision);
importPackage(com.jme3.scene.debug);
importPackage(com.jme3.scene);
importPackage(com.jme3.material);

var block = new Object(); 
var counter = 0;
//This section gets call once on game startup
//thisBlock variable is created by the script evaluator and is a com.blocks.blocks.Block instance.
block.setup = function(name) {
 	thisBlock.setName("Counter");
 	thisBlock.setTextureRow(0.0);
	thisBlock.setTextureColumn(8.0);
 	thisBlock.resetTexture();
	
	
} 
//This method gets called once per game loop
block.loop = function(name, tpf) { 
	if(thisBlock.isPowered()){
		if(!thisBlock.isHudBlock()){
		
				var frequency = thisBlock.getFrequency(thisBlock.getBlockSides());
				if(frequency>0){
					counter = ((counter+tpf)%frequency); 
				}else {
					counter = 0.0;
				}
				
				if(frequency>0){
					thisBlock.setAllFrequency(new Float(counter+1).intValue());	
				}
			}else {
				thisBlock.setAllFrequency(0);
				counter = 0;
			}
				
	}	
 }


block.scriptExport = function() {
	return ("");
} 


